<div class="container-fluid">
    <div class="block-header">
        <h2>语言 > 管理语言</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="header">
                    <h2>管理 & 编辑语言</h2>
                </div>
                <div class="body">
                   <div class="table-responsive1">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                                <tr>
                                	<th>ID</th>
                                    <th>Key名称</th>
                                    <th>语言值</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
					            $langs = Wo_LangsFromDB($_GET['id']);
					            if (count($langs) > 0) {
					            	$count = 1;
					                foreach ($langs as $wo['lang_key'] => $wo['langs']) {
					                	$wo['langs'] = $wo['langs'];
					                	$wo['lang_id'] = $count++;
					                    echo Wo_LoadAdminPage('edit-lang/list');
					                }
					            }  
					            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>
$('.btn-lang').on('click', function(event) {
	$('.modal-body form .data').html('<div class="preloader pl-size-xl "><div class="spinner-layer pl-teal"><div class="circle-clipper left"><div class="circle"></div></div><div class="circle-clipper right"><div class="circle"></div></div></div></div>');
	var lang_id = $(this).attr('data-id');
	$.get(Wo_Ajax_Requests_File() + '?f=get_lang_key', {id: lang_id, lang_name: '<?php echo $_GET['id']; ?>'}, function(data, textStatus, xhr) {
		$('.modal-title').html('编辑语言: ' + lang_id);
		$('#id_of_key').val(lang_id);
		$('.modal-body form .data').html(data.html);
	});
});
$(function () {
	$('table').DataTable();
	var form_lang_settings = $('form.edit-key-settings');
    form_lang_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_lang_key&hash=' + $('.main_session').val(),
        beforeSend: function() {
            $('.btn-save').text('请稍后..');
        },
        success: function(data) {
            if (data.status == 200) {
            	$('.btn-save').text('保存修改');
            	var value_to_use = $('[data-editable=1]').val();
            	var id_of_key = $('#id_of_key').val();
            	$('#edit_' + id_of_key).text(value_to_use);
            	$('#defaultModal').modal('hide');
            }
        }
    });
});
function Wo_SubmitLangForm() {
	$('.edit-key-settings').submit();
}
</script>
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header">
                <h4 class="modal-title" id="defaultModalLabel"></h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-success edit-lang-settings-alert"></div>
                <form class="edit-key-settings" method="POST">
                	<div class="data"></div>
                	<input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                	<input type="hidden" name="id_of_key" id="id_of_key" value="">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="Wo_SubmitLangForm();" class="btn-save btn btn-link waves-effect">保存修改</button>
                <button type="button" class="btn btn-link waves-effect" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>